//
//  HTDevelopEnvironmentSetting.m
//  CreditCommunity
//
//  Created by maiya on 2017/10/13.
//  Copyright © 2017年 maiya. All rights reserved.
//

#import "HTDevelopEnvironmentSetting.h"
@interface HTDevelopEnvironmentSetting ()

@property (nonatomic) NSInteger developEnvironment; // 主工程中环境宏的值

@end

@implementation HTDevelopEnvironmentSetting

+ (instancetype)sharedInstance {
    
    static HTDevelopEnvironmentSetting *_instance;
    
    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken, ^{
        _instance = [[HTDevelopEnvironmentSetting alloc] init];
    });
    return _instance;
}

#pragma mark - 接口切换 
-(void)defaultHostEnvironmentSetting:(NSInteger)envFlag {
    self.developEnvironment = envFlag;
    
    NSString *selectDev = [[NSUserDefaults standardUserDefaults] objectForKey:@"develop_seting"];
    if (selectDev.length > 0) {
        return; // 已经有默认的开发测试域名，则不做任何处理
    }
    if (self.developEnvironment == 1) {
        selectDev = @"开发环境app";
    }
    
    if (selectDev.length > 0) {
        // 保存
        [[NSUserDefaults standardUserDefaults] setObject:selectDev forKey:@"develop_seting"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}

#pragma mark - 程序主要接口Host
- (NSString *)getCurrentDevAPPHost {
    
    if (self.developEnvironment == 0) {
        return  @"线上环境";
    }
    
    
    // 默认的API host。
    NSString *host = @"https://preapp.开发环境.com";
    NSString *selectDev = [[NSUserDefaults standardUserDefaults] objectForKey:@"develop_seting"];
    if (selectDev.length < 1) {
        return host;
    }
    
    return @"";
}

#pragma mark - Web 接口
- (NSString *)getCurrentDevWebHost {
    
    if (self.developEnvironment == 0) {
        return @"线上环境";
    }
    
    NSString *host = @"https://preapp.开发环境.com";
    NSString *selectDav = [[NSUserDefaults standardUserDefaults] objectForKey:@"develop_seting"];
    if (selectDav.length > 1) {
        return host;
    }
    return @"";
}

#pragma mark - 文件上传接口
- (NSString*)getCurrentImageWithSoundRecordingHost {
    if (0 == self.developEnvironment) {
        // 线上环境
        
        return @"https://线上环境";
    } else {
        return @"https://开发环境";
    }
    
}

@end
